TYPES = (
    ("v8si", "V8SI", "V8SI"),
    ("uv8si", "V8SI", "unsigned_V8SI"),
    ("v4di", "V1OI", "V1OI"),
    ("uv4di", "V1OI", "unsigned_V1OI"),
    ("v4df", "V4DF", "V4DF"),
    ("v4sf", "V4SF", "V4SF"),
)

SCALAR_TYPES = (
    ("si", "SI", "intSI"),
    ("usi", "SI", "unsigned_intSI"),
    ("di", "DI", "intDI"),
    ("udi", "DI", "unsigned_intDI"),
    ("df", "DF", "double"),
    ("sf", "SF", "float")
)
cast_list = [(it, jt) for jt in TYPES for it in TYPES] + [(it, jt) for it, jt in zip(TYPES, SCALAR_TYPES)]  + [(jt, it) for it, jt in zip(TYPES, SCALAR_TYPES)]
protect_list = list(TYPES) + list(SCALAR_TYPES)
print("#ifdef BUILTIN_INC_CODES")
for it, jt in cast_list:
    if it[0] != jt[0]:
        print("PLUGIN_BUILTIN_cast_%s_%s," % (it[0], jt[0]))
for it in protect_list:
    print("PLUGIN_BUILTIN_protect_%s," % it[0])
    
print("#endif")

print("#ifdef BUILTIN_INC_ADD_BUILTIN")
for it, jt in cast_list:
    if it[0] != jt[0]:
        print("ADD_CAST_BUILTIN(%s, %s, %s_type_node, %s_type_node);" % (it[0], jt[0], it[2], jt[2]))
for it in protect_list:
    print("ADD_PROTECT_BUILTIN(%s, %s_type_node);" % (it[0], it[2]))
print("#endif")

print("#ifdef BUILTIN_INC_EXPAND_BUILTIN")
for it, jt in cast_list:
    if it[0] != jt[0]:
        print("case PLUGIN_BUILTIN_cast_%s_%s:" % (it[0], jt[0]))
        print("return expand_mode_cast(%smode, %smode, exp, target, ignore);" % (jt[1], it[1]))
for it in protect_list:
    print("case PLUGIN_BUILTIN_protect_%s:" % it[0])
    print("return expand_protect(%smode, exp, target, ignore);" % it[1])
print("#endif")

